import Mock from 'mockjs'

let registerList = [] //把存所有账号

export default {
  registerData: config => { 
    let { val, pass } = JSON.parse(config.body);
    registerList.push({
      val: val,
      pass:pass
    })
    return {
      data:registerList
    }
  },
  loginData: (config) => {
    let { val, pass } = JSON.parse(config.body);
    let token = "";
    
    let obj = registerList.find(item => { 
      return item.val ===val && item.pass ===pass
    })
    if (obj) {
      token = Mock.mock('@string')
    }  else {
      return {
        code: "101",
        msg: "账号密码错误",
        data: null,
      };
    }
    return {
      code: "200",
      msg: "登录成功",
      data: token,
    };
  },
};
